'use strict'

define([ 'jquery', 'bootstrap', 'select2', 'bodyform', 'validate',
        'validate.en' ], function($) {
    return {
        init : function(data) {
            this.initPage();
        },
              
        initPage: function() {
              
            $('select').select2({
		      theme: "classic",
		      placeholder : '请选择',
		      minimumResultsForSearch : -1,
		      allowClear : true
		    });
            
            var $form = $('form[data-validate="true"]')
            $form.bt_validate()  //bind validate
            $form.bodyform({
              showModal: true,
              beforeSubmit : function(el) {
            	  $form.trigger("validate.ajax.submit");
                return $.bt_validate.result[$.bt_validate.form_id]
              }
            })
            
            $(document).on("redirect", "body", function() {
              window.location.href=window.__CTX__.root + "/survey/success"
            })
        }

    }
})
